package classes.Commands
{
	import components.editor.c_baseEditor;
	import components.editor.c_baseElement;
	
	public class c_deleteAll extends c_commandFromEditor {
		private var _list			: Array;
		
		public function c_deleteAll(a_editor: c_baseEditor) {
			super(a_editor);
			//_list = new Array();
		}

		override public function Execute():void {
			super.Execute();
			//_list.splice(0, _list.length);
			
			_list = editor.getVisibleElems(c_baseElement);
/*			
			editor.imageLayer.forEach(function(elem: c_baseElement): void {
				if (elem.visible) _list.push(elem);
			}, c_baseElement);*/
			
			for (var i: int=0; i<_list.length; i++)
				(_list[i] as c_baseElement).remove();
		}
		
		override public function unExecute():void {
			for (var i: int=0; i<_list.length; i++) {
				(_list[i] as c_baseElement).setParent(editor.imageLayer);
			}
			_list.splice(0, _list.length);
			super.unExecute();
		}
		
		override public function dispose():void {
			for (var i: int=0; i<_list.length; i++)
				(_list[i] as c_baseElement).dispose();
			_list.splice(0, _list.length);
		}		
	}
}